﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using EZCRS.HCMS.Entity;
using EZCRS.HCMS.Bll;
using EZCRS.HCMS.Web;
using EZCRS.HCMS.Bll.baseinfo;

namespace EZCRS.HCMS.Web.manage.hotel
{
    public partial class plan_edit : ManageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (base.BasHotelId == 0)
                Response.Write(CFun.AlertMeg(Resources.Site.MustHotel, "back", ""));

            if (!IsPostBack)
            {
                int id = CFun.RequestNumber("id");

                //InitPage();

                if (id > 0)
                {
                    HCRS_Plan item = new BllRatePlan().getItem(id);

                    if (item != null)
                    {
                        //CFun.bindpagedata<h_RateCode>(this, item);
                        BindData(item);
                    }
                }
            }
        }


        private void BindData(HCRS_Plan obj)
        {
            txtName.Text = obj.PlanName;
            labCode.Text = obj.PlanCode;

            txtDesc.Text = obj.PlanDesc;

            if (obj.available == 1)
                rblStatus.SelectedIndex = 0;
            else
                rblStatus.SelectedIndex = 1;

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            int id = CFun.RequestNumber("id");

            if (id > 0)
            {
                HCRS_Plan item = new BllRatePlan().getItem(id);

                item.PlanDesc = txtDesc.Text;
                item.PlanName = txtName.Text;
                item.available = 1 - rblStatus.SelectedIndex;

                item.updatetime = DateTime.Now;

                BllRatePlan bll = new BllRatePlan();

                if (bll.Update(item))
                    Response.Redirect("planlist.aspx");
                else
                {
                    Response.Write(CFun.AlertMeg(Resources.Site.SystemError, "back", ""));
                }
            }
        }


    }
}
